#ifndef ORG_LATESTBIT_SMARTOBJECTS_TESTMODEL_SIMPLECHOICE_INL
#define ORG_LATESTBIT_SMARTOBJECTS_TESTMODEL_SIMPLECHOICE_INL










namespace org_latestbit_smartobjects_testmodel {
inline SimpleChoice::SimpleChoice()






{}

inline SimpleChoice::SimpleChoice(const ISimpleChoice& src)






{
    copyFrom(src);
}

inline void SimpleChoice::operator = (const ISimpleChoice& src)
{
    copyFrom(src);
}


inline SimpleChoice::~SimpleChoice() {
}

inline const std::string& SimpleChoice::getObjectType() const {
    const static std::string OBJECT_TYPE =  "org.latestbit.smartobjects.testmodel.SimpleChoice";
    return OBJECT_TYPE;
}

const std::string& SimpleChoice::getSelectedFieldName() const {
    return m_sSelectedField;
}




inline  const  BigInteger& SimpleChoice::getIntVal() const {
    return intVal;
}


inline BigInteger& SimpleChoice::refIntVal() {
    return intVal;
}



inline void SimpleChoice::setIntVal(const BigInteger& value) {
    intVal = value;
    m_sSelectedField = ISimpleChoice::INTVAL_SELECTED_FIELD();
}


inline bool SimpleChoice::isIntValSelected() {
    return m_sSelectedField == (ISimpleChoice::INTVAL_SELECTED_FIELD());
}




inline  const  std::string& SimpleChoice::getStrVal() const {
    return strVal;
}


inline std::string& SimpleChoice::refStrVal() {
    return strVal;
}



inline void SimpleChoice::setStrVal(const std::string& value) {
    strVal = value;
    m_sSelectedField = ISimpleChoice::STRVAL_SELECTED_FIELD();
}


inline bool SimpleChoice::isStrValSelected() {
    return m_sSelectedField == (ISimpleChoice::STRVAL_SELECTED_FIELD());
}



inline void SimpleChoice::serialize(IDataTypesCoder* coder, IDataEncrypter* encrypter, ByteBuffer* writeBuffer) const {
    if(m_sSelectedField.empty()) {
        throw DataTypesCoderException("Choice 'SimpleChoice' doesn't have any selected items to encode!");
    }

    unsigned int beginPos = coder->encodeChoiceDataTypeBegin(writeBuffer);
    coder->encodeChoiceSelectedField(m_sSelectedField, writeBuffer);

    if(m_sSelectedField == (ISimpleChoice::INTVAL_SELECTED_FIELD())) {
        coder->encodeBigInteger(intVal, writeBuffer);
    }

    else if(m_sSelectedField == (ISimpleChoice::STRVAL_SELECTED_FIELD())) {
        coder->encodeString(strVal, writeBuffer);
    }

    else
        throw DataTypesCoderException("Choice 'SimpleChoice' selected unknown field name '"+m_sSelectedField+"'");

    coder->encodeChoiceDataTypeEnd(beginPos, writeBuffer);
}

inline void SimpleChoice::deserialize(IDataTypesCoder* coder, IDataEncrypter* encrypter,  ByteBuffer* readBuffer) {
    unsigned int beginPos = coder->decodeChoiceDataTypeBegin(readBuffer);
    coder->decodeChoiceSelectedField(m_sSelectedField, readBuffer);

    if(m_sSelectedField == (ISimpleChoice::INTVAL_SELECTED_FIELD())) {
        coder->decodeBigInteger(intVal, readBuffer);
    }

    else if(m_sSelectedField == (ISimpleChoice::STRVAL_SELECTED_FIELD())) {
        coder->decodeString(strVal, readBuffer);
    }

    else
        throw DataTypesCoderException("Choice 'SimpleChoice' selected unknown field name '"+m_sSelectedField+"'");

    coder->decodeChoiceDataTypeEnd(beginPos, readBuffer);
}

inline void SimpleChoice::copyFrom(const ISimpleChoice& src) {
    intVal = src.getIntVal();
    strVal = src.getStrVal();
    m_sSelectedField = src.getSelectedFieldName();
}
}

#endif // ORG_LATESTBIT_SMARTOBJECTS_TESTMODEL_SIMPLECHOICE_INL
